package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//SjshDdb 国际结算量导入
type SjshDdb struct {
	ID   int     `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF int     `gorm:"column:KHYF"`
	KHJL string  `gorm:"column:KHJL;size:100"`
	JE   float64 `gorm:"column:JE"`
	EMID int     `gorm:"column:EMID"`
}

//SjshDdbAfterImport 导入后执行
func SjshDdbAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	err = tx.Exec("UPDATE T_BASE_YXFY_SJSHDDB SET EMID=B.ID "+
		"FROM T_BASE_YXFY_SJSHDDB A INNER JOIN T_SysUser B ON (A.KHJL=B.SysUserName) OR (A.KHJL=B.SysUserID)"+
		"WHERE KHYF=?", params["KHYF"]).Error
	if err != nil {
		return err
	}
	return nil
}

//TableName 随借随还短贷宝导入表
func (SjshDdb) TableName() string {
	return "T_BASE_YXFY_SJSHDDB"
}

//SjshDdbEF 返回结构体
func SjshDdbEF() base.EntityFunc {
	return func() interface{} {
		entity := SjshDdb{}
		return &entity
	}
}

//SjshDdbESF 返回结构体数组
func SjshDdbESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []SjshDdb
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("SjshDdb", base.NewDefaultDao(SjshDdbEF(), SjshDdbESF(), nil))
	base.SetAfterCallBack("SjshDdb", SjshDdbAfterImport)

}
